--
-- Description: View for displaying the list of events.
-- Date created: 6 May 2008
--

set ANSI_NULLS on
set QUOTED_IDENTIFIER on
go

--
-- drop the view if it exists and recreate it.
--
if exists
(
	select * 
	from sys.views
	where object_id = OBJECT_ID(N'[dbo].[Events_vw]')
)
begin
	drop view [dbo].[Events_vw]
end
go

create view [dbo].[Events_vw] 
as
	select
	E.[EventID]
	, ET.[EventTypeName]
	, E.[DateCreated]
	, E.[DateModified]
	, E.[TotalHits]
	, E.[ApplicationName]
	, E.[ApplicationVersion]
	, E.[ApplicationStampDate]
	, E.[ModuleName]
	, E.[ModuleVersion]
	, E.[ModuleStampDate]
	, E.[Offset]
	, E.[ExceptionCode]
	, FE.[FileID]
	from [dbo].[Events] E (nolock)
	inner join [dbo].[EventTypes] ET (nolock)
		on E.EventTypeID = ET.EventTypeID
	inner join [dbo].[FilesEvents] FE (nolock)
		on FE.EventID = E.EventID
		and FE.EventTypeID = E.EventTypeID
go
